<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
<title>图片渐变效果</title>

<img src="1.jpg" id="myImage" style="border:1px solid #000000;opacity:0">
<script type="text/javascript">
var b = 1;
var c = true;
function latent()
{
  if(c == true) 
  	b++;
  else 
  	b--;
  if(b==100)
  {
    b--;
    c = false
  }
  if(b==10)
  {
    b++;
    c = true;
  }
  myImage.style.opacity=b/100;
  setTimeout("latent()",25);
}
latent();
</script>
</head>
<body>
</body>
</html>
